<template>
  <!--推送配置-->
  <div class="search">
    <f-form ref="form" form-key="oss">
      <f-form-item label="推送提供商" name="serviceName" type="select" :data="api.common.pushType" :value.sync="serviceName" width="400px"/>
      <f-form-item label="accessKey" name="appKey" :required="true" :value="config.appKey" width="400px"/>
      <f-form-item label="secretKey" name="secretKey" :required="true" :value="config.secretKey" width="400px"/>
    </f-form>
  </div>
</template>

<script>
  export default {
    name: 'pushForm',
    props: {},
    data () {
      return {
        isAdd: true,
        serviceName: 'PUSH_JG',
        config: {
          appKey: '',
          secretKey: ''
        }
      }
    },
    methods: {
      getData () {
        this.http.get(this, {
          url: this.api.config.get,
          data: {
            configType: 'push'
          },
          success: function (me, data) {
            if (data.PUSH_CONFIG) {
              let result = JSON.parse(data.PUSH_CONFIG)
              me.config.appKey = result.appKey
              me.config.secretKey = result.secretKey
              me.serviceName = result.serviceName
            }
          }
        })
      },
      setData () {
        this.$refs.form.resetFields()
        this.getData()
      },
      handleSubmit () {
        this.$refs.form.getForm().validateFields((valid, values) => {
            if (!valid) {
              this.http.post(this, {
                url: this.api.config.pushSave,
                data: {
                  params: values
                },
                success: function (me) {

                }
              })
            }
          }
        )
      }
    },
    computed: {},
    created () {
      //this.getData()
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
